#include <catch2/catch.hpp>

#include <array>

#include "solution.hpp"

using namespace solution_092;

TEST_CASE("92. Reverse Linked List II", "[092]") {

std::array n{ ListNode(1), ListNode(2), ListNode(3), ListNode(4), ListNode(5) };
for (size_t i = 0, j = 1; j < n.size(); ++i, ++j)
    n[i].next = &n[j];
auto node = Solution().reverseBetween(&n[0], 2, 4);
for (auto v : {1,4,3,2,5}) {
    CHECK(node->val == v);
    node = node->next;
}
CHECK(node == nullptr);

}
